/*
 * Triangles
 *
 * Copyright (c) 2007 Xaveer Leijtens
 *
 * This file is part of libMask.
 *
 * libMask is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * libMask is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with libMask.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "mask.h"

/* Draw a triangle in the coordinate system defined by the current pointer,
 * leaving the position at the current pointer.
 */
void triangle(double x1, double y1, double x2, double y2)
{
  double x[2], y[2];

  push_cp();
  x[0] = cp.x;
  y[0] = cp.y;
  org(x1, y1, 0, NOFLIP);
  x[1] = cp.x;
  y[1] = cp.y;
  org(x2, y2, 0, NOFLIP);
  mskpolygon3(clayer,x[0],y[0],x[1],y[1],cp.x,cp.y);
  pop_cp();
}

/* Draw an isosceles triangle, with two sides of equal length, starting at
 * the current pointer, with a width of the base w and height h.
 * leaving the position at the top of the triangle.
 */
void isosceles_triangle(double w, double h)
{
  push_cp();
  offset(w/2);
  triangle(0,w,h,w/2);
  pop_cp();
  skip(h);
}

